package com.xbb.controller.user;

import com.xbb.mapper.LeavesMapper;
import com.xbb.mapper.NoticeMapper;
import com.xbb.mapper.QuestionnaireMapper;
import com.xbb.mapper.UserMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
public class IndexController {

    private String prefix = "/user/";

    @Resource
    private UserMapper userMapper;
    @Resource
    private QuestionnaireMapper questionnaireMapper;
    @Resource
    private NoticeMapper noticeMapper;
    @Resource
    private LeavesMapper leavesMapper;

    // 后台首页
    @RequestMapping("/index.html")
    public String indexHtml () {
        return prefix + "index";
    }

    @RequestMapping("/home.html")
    public String homeHtml (Model model) {
        int count1 = userMapper.selectCountByPaging(null, null, null);
        int count2 = questionnaireMapper.selectCountByPaging(null, null);
        int count3 = noticeMapper.selectCountByPaging(null);
        int count4 = leavesMapper.selectCountByPaging(null, null, null, null);
        model.addAttribute("count1", count1);
        model.addAttribute("count2", count2);
        model.addAttribute("count3", count3);
        model.addAttribute("count4", count4);
        return prefix + "home";
    }

}
